Show language: C# VB.NET Both
In the event that the encoding of a document or documents is not identified correctly, the Central Event System can be used to modify the encoding used. For example, .TXT files do not contain any header information about the encoding that they are saved in (except for BOMs when present). If the encoding is not returned by the server (which is unlikely) then UTF-8 is assumed. This may cause trouble with non English language files. As the search engine does not have enough information to properly read the file, the Central Event System can be used to provide that information. Please see the Central Event System section for general information on it.
Note: The encoding of HTML files is read either from the server response or from a standard meta tag containing the charset identifier (if present).
The following Action event handler will wait for a document with URL "http://host/myfile.txt" and set it's encoding to "Windows-1250". This can easily be modified to set encodings for any range of files as desired.
private void CentralEventDispatcher_Action(object sender, Keyoti.SearchEngine.Events.ActionEventArgs e)
{
if(e.ActionData.Name==Keyoti.SearchEngine.Events.ActionName.UseDocumentEncoding)
{
if( (e.ActionData.Data as Document).Uri.AbsoluteUri == "http://host/myfile.txt")
{
(e.ActionData.Data as Document).Encoding = System.Text.Encoding.GetEncoding("Windows-1250");
}
}
}
Private Sub CentralEventDispatcher_Action(ByVal sender As Object, ByVal e As Keyoti.SearchEngine.Events.ActionEventArgs)
If (e.ActionData.Name = Keyoti.SearchEngine.Events.ActionName.UseDocumentEncoding) Then
If (CType(e.ActionData.Data,Document).Uri.AbsoluteUri = "http://host/myfile.txt") Then
CType(e.ActionData.Data,Document).Encoding = System.Text.Encoding.GetEncoding("Windows-1250")
End If
End If
End Sub